
import 'package:flutter/cupertino.dart';

class NavigationUtil {
  static void pushPage(
      BuildContext context,
      Widget page,
      {
        String pageName,
      })

  {
    if (context == null || page == null) return;
    Navigator.push(context, new CupertinoPageRoute<void>(builder: (ctx) => page));
  }

  static void presentPage(
      BuildContext context,
      Widget page,
      {
        String pageName,
      })

  {
    if(context == null || page == null) return;
    Navigator.push(context, new CupertinoPageRoute<void>(fullscreenDialog: true,builder: (ctx) => page));
  }

  static void popAndPushPage(
      BuildContext context,
      Widget page,{String pageName})
  {
    if(context == null || page == null) return;
    Navigator.popAndPushNamed(context, pageName);
  }

  static void popAllAndPushName(BuildContext context,String pageName) {
    if(context == null || pageName == null) return;
    Navigator.pushNamedAndRemoveUntil(context, pageName, ModalRoute.withName(pageName));
  }

  static void replacePage(BuildContext context, Widget page) {
    if(context == null || page == null) return;
    Navigator.pushReplacement(context, new CupertinoPageRoute<void>(builder: (ctx) => page));
  }

  static void pop(BuildContext context) {
    if(context == null) return;
    Navigator.of(context).pop();
  }

  // static void pushPageAndBloc(BuildContext context, Widget page) {
  //   pushPage(context, page);
  // }

  // static void pushPageAndBloc<T extends BlocBase>(BuildContext context, Widget page, T bloc) {
  //   pushPage(context, BlocProvider<T>(
  //     child: page,
  //     bloc: bloc,
  //   ));
  // }

//  static void pushURL(BuildContext context, String url, {String title}) {
//    if (context == null || url == null) return;
//    if (!url.startsWith("http")) {
//      launchOtherApp(url);
//    } else if (url.endsWith(".apk")) {
//      launchOtherApp(url);
//    } else if(url.startsWith("https://itunes.apple.com")){
//      launchOtherApp(url);
//    } else {
////      Navigator.push(
////          context,
////          new CupertinoPageRoute<void>(
////              builder: (ctx) => WebViewPage(
////                url: url,
////                title: title,
////              )));
//    }
//  }

//  static Future<Null> launchOtherApp(String url) async {
//    if (await canLaunch(url)) {
//      await launch(url);
//    }
//  }

}

/*传值封装类*/
class QuotesSymbols{

  String baseCoin;
  String priceCoin;

  QuotesSymbols(this.baseCoin,this.priceCoin);
}

/*云钱包model*/
class WalletSymbols {

  String coin;
  WalletSymbols(this.coin);
}
